<template>
	<view>
		<view class="publish-bg" :style="{backgroundImage:'url('+ backgroundImage +')'}">
			<uv-navbar leftIconSize="0"  bgColor="transparent" titleStyle="color:#fff;font-weight: bold;font-size: 32rpx;" title="发布"
				:safeAreaInsetTop="true" >
			</uv-navbar> 
		</view>
		<view style="padding-bottom: 100rpx;">
			<view class="items" @click="toTask">
				<image src="@/static/images/task.png" mode="widthFix"></image>
				<view class="content-item">
					<view class="title">
						找伴任务
					</view>
					<view class="slogan">
						 找对的伴，攒好的局！ 
					</view>
				</view>
				<image class="enter-img" src="@/static/images/enter_hei.png" mode="widthFix"></image>
			</view>
			<view class="items" style="margin-top: 40rpx;background: #F1F2FF;" @click="toGroup">
				<image src="@/static/images/group.png" mode="widthFix"></image>
				<view class="content-item">
					<view class="title">
						组局活动
					</view>
					<view class="slogan">
						局对了，生活就对了！
					</view>
				</view>
				<image class="enter-img" src="@/static/images/enter_hei.png" mode="widthFix"></image>
			</view>
		</view>
		<tabbar :current="2"></tabbar>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import tabbar from '@/components/tabbar/tabbar' //引用组件中的tabbar
	import {
		onLoad
	} from "@dcloudio/uni-app";
	import {
		useActiveStore
	} from '@/store/modules/active.js'
	const activeStore = useActiveStore()
	// 初始化顶部距离为0
	const statusBarHeight = ref(0)
	const backgroundImage = ref('')
	onLoad(() => {
		// 获取系统信息
		uni.getSystemInfo({
			success: (res) => {
				if (res.safeArea&&res.safeArea.top>0) {
					statusBarHeight.value = res.safeAreaInsets.top;
				} else {
					statusBarHeight.value = 24;
				}
			}
		})
		getBannerList()
	})
	// 获取banner图
	const getBannerList = async () => {
		let res = await activeStore.getBannerList({
			position: 3
		})
		if (res.code == 200) {
			backgroundImage.value = uni.getStorageSync('baseUrl') + res.data[0].image
		}
	}
	const toTask = () => {
		let info = JSON.parse(uni.getStorageSync('user'));
		if (info && info.userInfo) {
			if(info.userInfo.examine!='0'){
				 uni.navigateTo({
				 	url: '/pages/release/findtask/index'
				 })
			 }else {
			 uni.$uv.toast('认证用户才能发布找伴活动~')
		}
		} 
		
	}
	const toGroup = () => {
		let info = JSON.parse(uni.getStorageSync('user'));
		if (info && info.userInfo) {
			if(info.userInfo.examine!='0'){
				uni.navigateTo({
					url: '/pages/release/organize/index'
				})
			 } else {
			 uni.$uv.toast('认证用户才能发布组局活动~')
		}
		}
		
	}
</script>

<style lang="scss" scoped>
	.publish-bg {
		background-size: cover;
		width: 100%;
		height: 688rpx;
	}

	.navbar-title {
		font-weight: bold;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
	}

	.items {
		display: flex;
		align-items: center;
		margin: 100rpx auto 40rpx auto;
		padding: 50rpx 40rpx;
		width: 654rpx;
		height: 200rpx;
		background: #D6F5F6;
		border-radius: 24rpx 24rpx 24rpx 24rpx;

		image {
			width: 100rpx;
			height: 100rpx;
		}

		.content-item {
			height: 100rpx;
			justify-content: space-between;
			flex: 1;
			margin-left: 40rpx;

			.title {
				font-weight: 800;
				font-size: 36rpx;
				color: #222222;
			}

			.slogan {
				padding-top: 10rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #222222;
			}
		}

		.enter-img {
			width: 28rpx;
			height: 28rpx;
		}
	}
</style>